﻿using Knowledge.EF.Back.Models.Users;
using Microsoft.EntityFrameworkCore;

namespace Knowledge.EF.Back.Models.DB
{
    public class EFCoreContext : DbContext
    {
        public EFCoreContext(DbContextOptions<EFCoreContext> options) : base(options) { }  
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
        }
        protected override void OnModelCreating(ModelBuilder modelbuilder)
        {
            modelbuilder.Entity<User>(u =>
            {
                u.Property(b => b.username).HasMaxLength(16);
                u.Property(b => b.password).HasMaxLength(12);
                u.Property(b => b.nickname).HasMaxLength(30);
                u.Property(b => b.email).HasMaxLength(30);
                u.Property(b => b.phone).HasMaxLength(11);
            });
        }

        public DbSet<User> Users { get; set; }
    }
}
